// 1.引入express
const express = require('express');

//  2.创建应用对象
const app = express();
// app.hostname="10.111.43.17"
app.all('/index_card', (request, response) => {
    //设置响应头 设置允许跨域
    response.setHeader('Access-Control-Allow-Origin', '*');
    //设置响应体
    // const swiper_list = [
    //     {
    //         image: 'https://tse1-mm.cn.bing.net/th/id/OET.cb5938bcaa074d36834d4474a5446271?w=272&h=272&c=7&rs=1&o=5&dpr=1.25&pid=1.9',
    //         title: " "
    //      },
    //     {
    //         image: 'https://tse1-mm.cn.bing.net/th/id/OET.21119ceae7d24964ac7037895acd5ae3?w=272&h=135&c=7&rs=1&o=5&dpr=1.25&pid=1.9',
    //         title: " "
    //     },
    //     {
    //         image: 'https://tse1-mm.cn.bing.net/th/id/OET.e24560fb06a7417a9cadc11c3679e290?w=272&h=135&c=7&rs=1&o=5&dpr=1.25&pid=1.9',
    //         title: " "
    //     }
    // ];
    // let str = JSON.stringify(swiper_list);
    // request.on('data',function(data){
    //     const obj=JSON.parse(data);
    //     console.log(obj);
    //     response.send('数据已接收')
    // });
    //商品卡片测试数据
    const index_card = [
        {
            name: '高钙苹果',
            address: '贵州省黔南布依族苗族自治州长顺县管顺镇石坂村马拜洞组',
            ispreasle: 0,
            price: 19.9,
            image: 'https://img.zcool.cn/community/019df0594aa737a8012193a3452085.jpg@1280w_1l_2o_100sh.jpg'
        },
        {
            name: '辣椒',
            address: '贵州省黔南布依族苗族自治州长顺县管顺镇石坂村马拜洞组',
            ispreasle: 1,
            price: 10.5,
            image: 'https://tse1-mm.cn.bing.net/th/id/R-C.c4a11d86f90e86ad5de06e0d57dae68d?rik=AjLn3SRoBJVjhw&riu=http%3a%2f%2fpic355.nipic.com%2ffile%2f20201215%2f31153231_210251017033_2.jpg&ehk=oBKy9mXtrCzAn6Z9T%2btQGfeUkh0lBU56%2byRnRYUg1Qs%3d&risl=&pid=ImgRaw&r=0'
        },
        {
            name: '高钙苹果',
            address: '贵州省黔南布依族苗族自治州长顺县管顺镇石坂村马拜洞组',
            ispreasle: 0,
            price: 19.9,
            image: 'https://tse1-mm.cn.bing.net/th/id/R-C.9dd7b084507bd58100b82bc7c010192c?rik=1bsS4H8RCfXtkQ&riu=http%3a%2f%2fimg.cgmodel.com%2fimage%2f2017%2f0520%2fcover%2f425638-1022808087.jpg&ehk=BsZ7NCP%2fVOWA0GIGjzTlCv%2bxziUVul9qlpm7wSC%2bqdY%3d&risl=&pid=ImgRaw&r=0'
        },
        {
            name: '辣椒',
            address: '贵州省黔南布依族苗族自治州长顺县管顺镇石坂村马拜洞组',
            ispreasle: 1,
            price: 10.5,
            image: 'https://ask.zhifure.com/upload/images/2020/12/9133957793.jpg'
        }
    ];
    response.send(index_card);
});

app.all('/need_card', (requests, response) => {
    //设置响应头 设置允许跨域
    response.setHeader('Access-Control-Allow-Origin', '*');
    // 需求数据
    let need_card = [
        {
            name: '高钙苹果',
            type: '水果',
            weight: 20,
            address: '贵州省黔南布依族苗族自治州长顺县管顺镇石坂村马拜洞组',
            deadline: '2021.11.9',
            image: 'https://img.zcool.cn/community/019df0594aa737a8012193a3452085.jpg@1280w_1l_2o_100sh.jpg',
            avatar: 'https://tse1-mm.cn.bing.net/th/id/R-C.54de638c56f650fc83e0033d5f4def28?rik=UhyNYfTgUzTuLA&riu=http%3a%2f%2fscimg.jianbihuadq.com%2ftouxiang%2f202003%2f2020030915105661.jpg&ehk=xc57MMdijyGCWsSaCAk3BNTfli7LMeDhzR8ov2n9zyE%3d&risl=&pid=ImgRaw&r='


        }, {
            name: '水晶葡萄',
            type: '水果',
            weight: 10,
            address: '贵州省黔南布依族苗族自治州长顺县管顺镇石坂村马拜洞组',
            deadline: '2021.11.9',
            image: 'https://tse1-mm.cn.bing.net/th/id/R-C.7ad9d9d4ae169449fccf9de8e7e0b214?rik=CiuNk6rTWIoCUg&riu=http%3a%2f%2fpic312.nipic.com%2ffile%2f20200722%2f21319742_214433973080_2.jpg&ehk=FZ1z%2bxxndAfgJyoo3tLefT3M4Eo9U7Rit97wRcn27%2f4%3d&risl=&pid=ImgRaw&r=0',
            avatar: 'https://tse3-mm.cn.bing.net/th/id/OIP-C.Y2OawgBWKA82D9c2bJYChQHaKy?w=182&h=265&c=7&r=0&o=5&dpr=1.25&pid=1.7'

        },
        {
            name: '辣椒',
            type: '蔬菜',
            weight: 100,
            address: '贵州省黔南布依族苗族自治州长顺县管顺镇石坂村马拜洞组',
            deadline: '2021.11.9',
            image: 'https://tse1-mm.cn.bing.net/th/id/OIP-C.CglGKvNohwuaK4BEM3RljAHaE8?pid=ImgDet&rs=1',
            avatar: 'https://tse1-mm.cn.bing.net/th/id/R-C.54de638c56f650fc83e0033d5f4def28?rik=UhyNYfTgUzTuLA&riu=http%3a%2f%2fscimg.jianbihuadq.com%2ftouxiang%2f202003%2f2020030915105661.jpg&ehk=xc57MMdijyGCWsSaCAk3BNTfli7LMeDhzR8ov2n9zyE%3d&risl=&pid=ImgRaw&r='


        }, {
            name: '玉米',
            type: '蔬菜',
            weight: 200,
            address: '贵州省黔南布依族苗族自治州长顺县管顺镇石坂村马拜洞组',
            deadline: '2021.11.9',
            image: 'https://tse1-mm.cn.bing.net/th/id/R-C.de96859092ff385ad269aff5225bcb18?rik=qsA36LMXpPBkCQ&riu=http%3a%2f%2fpic146.huitu.com%2fres%2f20200726%2f1541551_20200726215826521060_1.jpg&ehk=gvzG1ecSPZZwqQQezba2hI0Cs7kZDWri0TKYHZXq5hQ%3d&risl=&pid=ImgRaw&r=0',
            avatar: 'https://tse3-mm.cn.bing.net/th/id/OIP-C.Y2OawgBWKA82D9c2bJYChQHaKy?w=182&h=265&c=7&r=0&o=5&dpr=1.25&pid=1.7'

        },
        {
            name: '高钙苹果',
            type: '水果',
            weight: 20,
            address: '贵州省黔南布依族苗族自治州长顺县管顺镇石坂村马拜洞组',
            deadline: '2021.11.9',
            image: 'https://img.zcool.cn/community/019df0594aa737a8012193a3452085.jpg@1280w_1l_2o_100sh.jpg',
            avatar: 'https://tse1-mm.cn.bing.net/th/id/R-C.54de638c56f650fc83e0033d5f4def28?rik=UhyNYfTgUzTuLA&riu=http%3a%2f%2fscimg.jianbihuadq.com%2ftouxiang%2f202003%2f2020030915105661.jpg&ehk=xc57MMdijyGCWsSaCAk3BNTfli7LMeDhzR8ov2n9zyE%3d&risl=&pid=ImgRaw&r='


        },
        {
            name: '水晶葡萄',
            type: '水果',
            weight: 10,
            address: '贵州省黔南布依族苗族自治州长顺县管顺镇石坂村马拜洞组',
            deadline: '2021.11.9',
            image: 'https://tse1-mm.cn.bing.net/th/id/R-C.7ad9d9d4ae169449fccf9de8e7e0b214?rik=CiuNk6rTWIoCUg&riu=http%3a%2f%2fpic312.nipic.com%2ffile%2f20200722%2f21319742_214433973080_2.jpg&ehk=FZ1z%2bxxndAfgJyoo3tLefT3M4Eo9U7Rit97wRcn27%2f4%3d&risl=&pid=ImgRaw&r=0',
            avatar: 'https://tse3-mm.cn.bing.net/th/id/OIP-C.Y2OawgBWKA82D9c2bJYChQHaKy?w=182&h=265&c=7&r=0&o=5&dpr=1.25&pid=1.7'

        },
        {
            name: '辣椒',
            type: '蔬菜',
            weight: 100,
            address: '贵州省黔南布依族苗族自治州长顺县管顺镇石坂村马拜洞组',
            deadline: '2021.11.9',
            image: 'https://tse1-mm.cn.bing.net/th/id/OIP-C.CglGKvNohwuaK4BEM3RljAHaE8?pid=ImgDet&rs=1',
            avatar: 'https://tse1-mm.cn.bing.net/th/id/R-C.54de638c56f650fc83e0033d5f4def28?rik=UhyNYfTgUzTuLA&riu=http%3a%2f%2fscimg.jianbihuadq.com%2ftouxiang%2f202003%2f2020030915105661.jpg&ehk=xc57MMdijyGCWsSaCAk3BNTfli7LMeDhzR8ov2n9zyE%3d&risl=&pid=ImgRaw&r='


        },
        {
            name: '玉米',
            type: '蔬菜',
            weight: 200,
            address: '贵州省黔南布依族苗族自治州长顺县管顺镇石坂村马拜洞组',
            deadline: '2021.11.9',
            image: 'https://tse1-mm.cn.bing.net/th/id/R-C.de96859092ff385ad269aff5225bcb18?rik=qsA36LMXpPBkCQ&riu=http%3a%2f%2fpic146.huitu.com%2fres%2f20200726%2f1541551_20200726215826521060_1.jpg&ehk=gvzG1ecSPZZwqQQezba2hI0Cs7kZDWri0TKYHZXq5hQ%3d&risl=&pid=ImgRaw&r=0',
            avatar: 'https://tse3-mm.cn.bing.net/th/id/OIP-C.Y2OawgBWKA82D9c2bJYChQHaKy?w=182&h=265&c=7&r=0&o=5&dpr=1.25&pid=1.7'

        }
    ];
    response.setHeader('Access-Control-Allow-Origin', '*');
    response.send(need_card);
});
app.all('/myneed', (requests, response) => {
    //设置响应头 设置允许跨域
    // 需求数据
    let myneed = [
        {
            id: 1,
            time: '12月24日',
            need: [
                {
                    name: '高钙苹果',
                    type: '水果',
                    weight: 20,
                    address: '贵州省黔南布依族苗族自治州长顺县管顺镇石坂村马拜洞组',
                    deadline: '2021.11.9',
                    image: 'https://img.zcool.cn/community/019df0594aa737a8012193a3452085.jpg@1280w_1l_2o_100sh.jpg',
                    avatar: 'https://tse1-mm.cn.bing.net/th/id/R-C.54de638c56f650fc83e0033d5f4def28?rik=UhyNYfTgUzTuLA&riu=http%3a%2f%2fscimg.jianbihuadq.com%2ftouxiang%2f202003%2f2020030915105661.jpg&ehk=xc57MMdijyGCWsSaCAk3BNTfli7LMeDhzR8ov2n9zyE%3d&risl=&pid=ImgRaw&r='


                }, {
                    name: '水晶葡萄',
                    type: '水果',
                    weight: 10,
                    address: '贵州省黔南布依族苗族自治州长顺县管顺镇石坂村马拜洞组',
                    deadline: '2021.11.9',
                    image: 'https://tse1-mm.cn.bing.net/th/id/R-C.7ad9d9d4ae169449fccf9de8e7e0b214?rik=CiuNk6rTWIoCUg&riu=http%3a%2f%2fpic312.nipic.com%2ffile%2f20200722%2f21319742_214433973080_2.jpg&ehk=FZ1z%2bxxndAfgJyoo3tLefT3M4Eo9U7Rit97wRcn27%2f4%3d&risl=&pid=ImgRaw&r=0',
                    avatar: 'https://tse3-mm.cn.bing.net/th/id/OIP-C.Y2OawgBWKA82D9c2bJYChQHaKy?w=182&h=265&c=7&r=0&o=5&dpr=1.25&pid=1.7'

                },
            ]
        },
        {
            id: 2,
            time: '12月23日',
            need: [
                {
                    name: '辣椒',
                    type: '蔬菜',
                    weight: 100,
                    address: '贵州省黔南布依族苗族自治州长顺县管顺镇石坂村马拜洞组',
                    deadline: '2021.11.9',
                    image: 'https://tse1-mm.cn.bing.net/th/id/OIP-C.CglGKvNohwuaK4BEM3RljAHaE8?pid=ImgDet&rs=1',
                    avatar: 'https://tse1-mm.cn.bing.net/th/id/R-C.54de638c56f650fc83e0033d5f4def28?rik=UhyNYfTgUzTuLA&riu=http%3a%2f%2fscimg.jianbihuadq.com%2ftouxiang%2f202003%2f2020030915105661.jpg&ehk=xc57MMdijyGCWsSaCAk3BNTfli7LMeDhzR8ov2n9zyE%3d&risl=&pid=ImgRaw&r='


                }, {
                    name: '玉米',
                    type: '蔬菜',
                    weight: 200,
                    address: '贵州省黔南布依族苗族自治州长顺县管顺镇石坂村马拜洞组',
                    deadline: '2021.11.9',
                    image: 'https://tse1-mm.cn.bing.net/th/id/R-C.de96859092ff385ad269aff5225bcb18?rik=qsA36LMXpPBkCQ&riu=http%3a%2f%2fpic146.huitu.com%2fres%2f20200726%2f1541551_20200726215826521060_1.jpg&ehk=gvzG1ecSPZZwqQQezba2hI0Cs7kZDWri0TKYHZXq5hQ%3d&risl=&pid=ImgRaw&r=0',
                    avatar: 'https://tse3-mm.cn.bing.net/th/id/OIP-C.Y2OawgBWKA82D9c2bJYChQHaKy?w=182&h=265&c=7&r=0&o=5&dpr=1.25&pid=1.7'

                },
                {
                    name: '高钙苹果',
                    type: '水果',
                    weight: 20,
                    address: '贵州省黔南布依族苗族自治州长顺县管顺镇石坂村马拜洞组',
                    deadline: '2021.11.9',
                    image: 'https://img.zcool.cn/community/019df0594aa737a8012193a3452085.jpg@1280w_1l_2o_100sh.jpg',
                    avatar: 'https://tse1-mm.cn.bing.net/th/id/R-C.54de638c56f650fc83e0033d5f4def28?rik=UhyNYfTgUzTuLA&riu=http%3a%2f%2fscimg.jianbihuadq.com%2ftouxiang%2f202003%2f2020030915105661.jpg&ehk=xc57MMdijyGCWsSaCAk3BNTfli7LMeDhzR8ov2n9zyE%3d&risl=&pid=ImgRaw&r='


                },
            ]
        },
        {
            id: 3,
            time: '12月22日',
            need: [
                {
                    name: '水晶葡萄',
                    type: '水果',
                    weight: 10,
                    address: '贵州省黔南布依族苗族自治州长顺县管顺镇石坂村马拜洞组',
                    deadline: '2021.11.9',
                    image: 'https://tse1-mm.cn.bing.net/th/id/R-C.7ad9d9d4ae169449fccf9de8e7e0b214?rik=CiuNk6rTWIoCUg&riu=http%3a%2f%2fpic312.nipic.com%2ffile%2f20200722%2f21319742_214433973080_2.jpg&ehk=FZ1z%2bxxndAfgJyoo3tLefT3M4Eo9U7Rit97wRcn27%2f4%3d&risl=&pid=ImgRaw&r=0',
                    avatar: 'https://tse3-mm.cn.bing.net/th/id/OIP-C.Y2OawgBWKA82D9c2bJYChQHaKy?w=182&h=265&c=7&r=0&o=5&dpr=1.25&pid=1.7'

                },
                {
                    name: '辣椒',
                    type: '蔬菜',
                    weight: 100,
                    address: '贵州省黔南布依族苗族自治州长顺县管顺镇石坂村马拜洞组',
                    deadline: '2021.11.9',
                    image: 'https://tse1-mm.cn.bing.net/th/id/OIP-C.CglGKvNohwuaK4BEM3RljAHaE8?pid=ImgDet&rs=1',
                    avatar: 'https://tse1-mm.cn.bing.net/th/id/R-C.54de638c56f650fc83e0033d5f4def28?rik=UhyNYfTgUzTuLA&riu=http%3a%2f%2fscimg.jianbihuadq.com%2ftouxiang%2f202003%2f2020030915105661.jpg&ehk=xc57MMdijyGCWsSaCAk3BNTfli7LMeDhzR8ov2n9zyE%3d&risl=&pid=ImgRaw&r='


                },
                {
                    name: '玉米',
                    type: '蔬菜',
                    weight: 200,
                    address: '贵州省黔南布依族苗族自治州长顺县管顺镇石坂村马拜洞组',
                    deadline: '2021.11.9',
                    image: 'https://tse1-mm.cn.bing.net/th/id/R-C.de96859092ff385ad269aff5225bcb18?rik=qsA36LMXpPBkCQ&riu=http%3a%2f%2fpic146.huitu.com%2fres%2f20200726%2f1541551_20200726215826521060_1.jpg&ehk=gvzG1ecSPZZwqQQezba2hI0Cs7kZDWri0TKYHZXq5hQ%3d&risl=&pid=ImgRaw&r=0',
                    avatar: 'https://tse3-mm.cn.bing.net/th/id/OIP-C.Y2OawgBWKA82D9c2bJYChQHaKy?w=182&h=265&c=7&r=0&o=5&dpr=1.25&pid=1.7'

                }
            ]
        }
    ];
    response.setHeader('Access-Control-Allow-Origin', '*');
    requests.on('data', function (data) {
        const obj = JSON.parse(data);
        console.log(obj);
        response.send(myneed);
    })

});
app.post('/mycollect', (requests, response) => {
    let collectinfo = [
        {
            avatar: 'https://tse3-mm.cn.bing.net/th/id/OIP-C.Y2OawgBWKA82D9c2bJYChQHaKy?w=182&h=265&c=7&r=0&o=5&dpr=1.25&pid=1.7',
            username: '梓芳家的高钙苹果',
            ispresale: true,
            time: '2021/12/20',
            weight: '1t',
            remain: 0,
            name: '贵州长顺高钙苹果',
            price: '5.9/斤',
            image: [{
                id: 1,
                src: 'https://tse3-mm.cn.bing.net/th/id/OIP-C.Y2OawgBWKA82D9c2bJYChQHaKy?w=182&h=265&c=7&r=0&o=5&dpr=1.25&pid=1.7',
            },
                {
                    id: 2,
                    src: 'https://tse3-mm.cn.bing.net/th/id/OIP-C.Y2OawgBWKA82D9c2bJYChQHaKy?w=182&h=265&c=7&r=0&o=5&dpr=1.25&pid=1.7',
                },
                {
                    id: 3,
                    src: 'https://tse3-mm.cn.bing.net/th/id/OIP-C.Y2OawgBWKA82D9c2bJYChQHaKy?w=182&h=265&c=7&r=0&o=5&dpr=1.25&pid=1.7',
                }
            ]
        },
        {
            avatar: 'https://tse3-mm.cn.bing.net/th/id/OIP-C.Y2OawgBWKA82D9c2bJYChQHaKy?w=182&h=265&c=7&r=0&o=5&dpr=1.25&pid=1.7',
            username: '梓芳家的高钙苹果',
            ispresale: false,
            time: '2021/12/20',
            weight: '1t',
            remain: 0,
            name: '贵州长顺高钙苹果',
            price: '5.9/斤',
            image: [{
                id: 1,
                src: 'https://tse3-mm.cn.bing.net/th/id/OIP-C.Y2OawgBWKA82D9c2bJYChQHaKy?w=182&h=265&c=7&r=0&o=5&dpr=1.25&pid=1.7',
            },
                {
                    id: 2,
                    src: 'https://tse3-mm.cn.bing.net/th/id/OIP-C.Y2OawgBWKA82D9c2bJYChQHaKy?w=182&h=265&c=7&r=0&o=5&dpr=1.25&pid=1.7',
                },
                {
                    id: 3,
                    src: 'https://tse3-mm.cn.bing.net/th/id/OIP-C.Y2OawgBWKA82D9c2bJYChQHaKy?w=182&h=265&c=7&r=0&o=5&dpr=1.25&pid=1.7',
                }
            ]
        },
        {
            avatar: 'https://tse3-mm.cn.bing.net/th/id/OIP-C.Y2OawgBWKA82D9c2bJYChQHaKy?w=182&h=265&c=7&r=0&o=5&dpr=1.25&pid=1.7',
            username: '梓芳家的高钙苹果',
            ispresale: false,
            time: '2021/12/20',
            weight: '1t',
            remain: 10,
            name: '贵州长顺高钙苹果',
            price: '5.9/斤',
            image: [{
                id: 1,
                src: 'https://tse3-mm.cn.bing.net/th/id/OIP-C.Y2OawgBWKA82D9c2bJYChQHaKy?w=182&h=265&c=7&r=0&o=5&dpr=1.25&pid=1.7',
            },
                {
                    id: 2,
                    src: 'https://tse3-mm.cn.bing.net/th/id/OIP-C.Y2OawgBWKA82D9c2bJYChQHaKy?w=182&h=265&c=7&r=0&o=5&dpr=1.25&pid=1.7',
                },
                {
                    id: 3,
                    src: 'https://tse3-mm.cn.bing.net/th/id/OIP-C.Y2OawgBWKA82D9c2bJYChQHaKy?w=182&h=265&c=7&r=0&o=5&dpr=1.25&pid=1.7',
                }
            ]
        }
    ];
    response.setHeader('Access-Control-Allow-Origin', '*');
    requests.on('data', function (data) {
        const obj = JSON.parse(data);
        console.log(obj);
        response.send(collectinfo);
    })
    // const res = requests.body;
    // console.log(res);
    // response.send("数据已接受");
});
app.post('/wx/login', (requests, response) => {
    //设置响应头 设置允许跨域
    response.setHeader('Access-Control-Allow-Origin', '*');
    requests.on('data', function (data) {
        // const obj=JSON.parse(data);
        // console.log(obj);
        response.send('数据已接收')
    });
    // const res = requests.body;
    // console.log(res);
    // response.send("数据已接受");
});
app.all('/order_card',(requests,response)=>{
    //设置响应头 设置允许跨域
    // 需求数据
    let order_card = [
        {
            name: '高钙苹果',
            price: '5',
            state: '下单成功',
            address: '贵州省黔南布依族苗族自治州长顺县管顺镇石坂村马拜洞组',
            deadline: '2021.11.9',
            image: 'https://img.zcool.cn/community/019df0594aa737a8012193a3452085.jpg@1280w_1l_2o_100sh.jpg',

        }, {
            name: '水晶葡萄',
            price: '10',
            state: '下单成功',
            address: '贵州省黔南布依族苗族自治州长顺县管顺镇石坂村马拜洞组',
            deadline: '2021.11.9',
            image: 'https://tse1-mm.cn.bing.net/th/id/R-C.7ad9d9d4ae169449fccf9de8e7e0b214?rik=CiuNk6rTWIoCUg&riu=http%3a%2f%2fpic312.nipic.com%2ffile%2f20200722%2f21319742_214433973080_2.jpg&ehk=FZ1z%2bxxndAfgJyoo3tLefT3M4Eo9U7Rit97wRcn27%2f4%3d&risl=&pid=ImgRaw&r=0',
        },
        {
            name: '辣椒',
            price: '4',
            state: '下单成功',
            address: '贵州省黔南布依族苗族自治州长顺县管顺镇石坂村马拜洞组',
            deadline: '2021.11.9',
            image: 'https://tse1-mm.cn.bing.net/th/id/OIP-C.CglGKvNohwuaK4BEM3RljAHaE8?pid=ImgDet&rs=1',


        }, {
            name: '玉米',
            price: '7',
            state: '下单成功',
            address: '贵州省黔南布依族苗族自治州长顺县管顺镇石坂村马拜洞组',
            deadline: '2021.11.9',
            image: 'https://tse1-mm.cn.bing.net/th/id/R-C.de96859092ff385ad269aff5225bcb18?rik=qsA36LMXpPBkCQ&riu=http%3a%2f%2fpic146.huitu.com%2fres%2f20200726%2f1541551_20200726215826521060_1.jpg&ehk=gvzG1ecSPZZwqQQezba2hI0Cs7kZDWri0TKYHZXq5hQ%3d&risl=&pid=ImgRaw&r=0',

        },
        {
            name: '高钙苹果',
            price: '5',
            state: '下单成功',
            address: '贵州省黔南布依族苗族自治州长顺县管顺镇石坂村马拜洞组',
            deadline: '2021.11.9',
            image: 'https://img.zcool.cn/community/019df0594aa737a8012193a3452085.jpg@1280w_1l_2o_100sh.jpg',


        }, {
            name: '水晶葡萄',
            price: '10',
            state: '下单成功',
            address: '贵州省黔南布依族苗族自治州长顺县管顺镇石坂村马拜洞组',
            deadline: '2021.11.9',
            image: 'https://tse1-mm.cn.bing.net/th/id/R-C.7ad9d9d4ae169449fccf9de8e7e0b214?rik=CiuNk6rTWIoCUg&riu=http%3a%2f%2fpic312.nipic.com%2ffile%2f20200722%2f21319742_214433973080_2.jpg&ehk=FZ1z%2bxxndAfgJyoo3tLefT3M4Eo9U7Rit97wRcn27%2f4%3d&risl=&pid=ImgRaw&r=0',

        },
        {
            name: '辣椒',
            price: '4',
            state: '下单成功',
            address: '贵州省黔南布依族苗族自治州长顺县管顺镇石坂村马拜洞组',
            deadline: '2021.11.9',
            image: 'https://tse1-mm.cn.bing.net/th/id/OIP-C.CglGKvNohwuaK4BEM3RljAHaE8?pid=ImgDet&rs=1',


        }, {
            name: '玉米',
            price: '7',
            state: '下单成功',
            address: '贵州省黔南布依族苗族自治州长顺县管顺镇石坂村马拜洞组',
            deadline: '2021.11.9',
            image: 'https://tse1-mm.cn.bing.net/th/id/R-C.de96859092ff385ad269aff5225bcb18?rik=qsA36LMXpPBkCQ&riu=http%3a%2f%2fpic146.huitu.com%2fres%2f20200726%2f1541551_20200726215826521060_1.jpg&ehk=gvzG1ecSPZZwqQQezba2hI0Cs7kZDWri0TKYHZXq5hQ%3d&risl=&pid=ImgRaw&r=0',
        }
    ];
    response.setHeader('Access-Control-Allow-Origin','*');
    response.send(order_card);
});
app.post('/goodsinfo', (requests, response) => {
    //设置响应头 设置允许跨域
    response.setHeader('Access-Control-Allow-Origin', '*');
    let goods_list = {
        uuid: '12341234', //商品uuid
        liaisonman: '肖先生', //联系人
        phone: '15708634609',
        name: '高钙苹果', //商品名
        type: '红富士',
        weight: '2000',
        price: '123', // 价格
        adress: '贵州省黔南布依族苗族自治州长顺县管顺镇石坂村马拜洞组贵州省黔南布依族苗族自治州长顺县管顺镇石坂村马拜洞组贵州省黔南布依族苗族自治州长顺县管顺镇石坂村马拜洞组', //地址
        ispresale: 0, //是否预售
        new_time: '2020-12-12', //如果预售，预售时间
        great_time: '2021-10-19', //发布时间
        remark: 'eneneneaaaa', // 备注
        imagelist: [
            {
                image: 'https://tse1-mm.cn.bing.net/th/id/OET.cb5938bcaa074d36834d4474a5446271?w=272&h=272&c=7&rs=1&o=5&dpr=1.25&pid=1.9',
                title: " "
            },
            {
                image: 'https://tse1-mm.cn.bing.net/th/id/OET.21119ceae7d24964ac7037895acd5ae3?w=272&h=135&c=7&rs=1&o=5&dpr=1.25&pid=1.9',
                title: " "
            },
            {
                image: 'https://tse1-mm.cn.bing.net/th/id/OET.e24560fb06a7417a9cadc11c3679e290?w=272&h=135&c=7&rs=1&o=5&dpr=1.25&pid=1.9',
                title: " "
            }
        ]
    };
    requests.on('data', function (data) {
        const obj = JSON.parse(data);
        console.log(obj);
        response.send(goods_list);
    });
    // const res = requests.body;
    // console.log(res);
    // response.send("数据已接受");
});
app.all('/getuserinfo', (requests, response) => {
    //设置响应头 设置允许跨域
    response.setHeader('Access-Control-Allow-Origin', '*');
    let userinfo = {
        openid: 'qwer1234123wedgwerfe2314cas3',
        username: '赵久燚',
        phone: '19820102938',
        adress: '贵州省黔南布依族苗族自治州长顺县管顺镇石坂村马拜洞组',
        user_status: 1

    };
    requests.on('data', function (data) {
        const obj = JSON.parse(data);
        console.log(obj);
        response.send(userinfo);
    });
    // const res = requests.body;
    // console.log(res);
    // response.send("数据已接受");
});
app.all('/fuzzy_query', (requests, response) => {
    let arr = [
        {
            id: 1,
            title: "我是模糊查询1"
        },
        {
            id: 2,
            title: "我是模糊查询2"
        },
        {
            id: 3,
            title: "我是模糊查询3"
        },
        {
            id: 4,
            title: "我是模糊查询4"
        },
        {
            id: 5,
            title: "我是模糊查询5"
        },
        {
            id: 6,
            title: "我是模糊查询6"
        }
    ];
    response.setHeader('Access-Control-Allow-Origin', '*');
    // let data = 11111;
    setTimeout(() => {
        requests.on('data', function (data) {
            const obj = JSON.parse(data);
            console.log(obj);
            response.send(JSON.stringify(arr));
        });
    }, 500);

});
app.post('/product_submit', (requests, response) => {
    response.setHeader('Access-Control-Allow-Origin', '*');
    requests.on('data', function (data) {
        console.log(typeof data);
        const submit = JSON.parse(data);
        console.log(submit);
        console.log(typeof submit);
        response.sendStatus(200);
    });
});
app.all('/search', (requests, response) => {
    response.setHeader('Access-Control-Allow-Origin', '*');
    let data = [
        {
            id: 1,
            value: '这是返回的搜索信息1',
        },
        {
            id: 2,
            value: '这是返回的搜索信息2',
        },
        {
            id: 3,
            value: '这是返回的搜索信息3',
        },
        {
            id: 4,
            value: '这是返回的搜索信息4',
        }
        ,
        {
            id: 5,
            value: '这是返回的搜索信息5',
        }
        ,
        {
            id: 6,
            value: '这是返回的搜索信息6',
        }
    ];
    response.send(JSON.stringify(data));
});
app.listen(8000, () => {
    console.log("服务已经启动，8000 端口监听中....");
});
